﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Script.Services;
using System.Web.Services;
using Duet.Model.Facade;
using Duet.Model.Core.Entities;

namespace Duet.Web.Forms
{
    [ScriptService]
    public partial class Ajax : System.Web.UI.Page
    {
        [WebMethod]
        public static string GetNames(string dtEvento)
        {
            string res = null;

            try
            {
                Casamento obj = new Casamento();
                DateTime min = DateTime.MinValue;

                if (DateTime.TryParse(dtEvento.Trim(), out min))
                {
                    DateTime dt = Convert.ToDateTime(dtEvento);

                    if (dt >= DateTime.Today)
                    {
                        obj = CasamentoFacade.GetWeddingByWeddingDate(dt);

                        if (obj != null)
                            res = obj.NmNoiva + " & " + obj.NmNoivo;
                    }
                    else
                    {
                        res = "dataantiga";
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            return res;
        }
    }
}